package com.example.hellonotes;

import com.example.hellonotes.activity.MainActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;


public class BaseFragment extends Fragment {
	
	/**
	 * 在基类中 使用 getActivity()方法获取当前碎片相关的Activity context上下文对象
	 */
	protected MainActivity activity;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		/**
		 * Return the Activity this fragment is currently associated with
		 * 返回这个碎片目前相关的Activity
		 */
		activity = (MainActivity) getActivity();
	}
	
	protected void intent2Activity(Class<? extends Activity> tarActivity) {
		Intent intent = new Intent(activity, tarActivity);
		startActivity(intent);
	}
}
